package com.example.pushdeom.Bean;

import android.content.Context;
import android.content.SharedPreferences;

public class AppSharedPreferences {
    private static final String PREFERENCE_NAME = "pushdeom_params_pref";

    public static void setPreference(Context context,String key,int value){
        SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME,0).edit();
        editor.putInt(key,value);
        editor.commit();
    }
    public static void setPreference(Context context,String key,String value){
        SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME,0).edit();
        editor.putString(key,value);
        editor.commit();
    }

    public static void setPreference(Context context, String key, Boolean value) {
        SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME, 0).edit();
        editor.putBoolean(key, value.booleanValue());
        editor.commit();
    }

    public static int getPreference(Context context,String key,int value){
        return context.getSharedPreferences(PREFERENCE_NAME,0).getInt(key,value);
    }

    public static boolean getPreference(Context context, String key, Boolean value){
        return context.getSharedPreferences(PREFERENCE_NAME,0).getBoolean(key,value.booleanValue());
    }

    public static String getPreference(Context context, String key, String value){
        return context.getSharedPreferences(PREFERENCE_NAME,0).getString(key,value);
    }

    public static void removePreference(Context context,String key){
        SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME,0).edit();
        editor.remove(key);
        editor.apply();
    }

    public static void clearPreference(Context context){
        SharedPreferences.Editor editor = context.getSharedPreferences(PREFERENCE_NAME,0).edit();
        editor.clear();
        editor.apply();
    }
}
